import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

enum Calendar { day, week, month, year }

class _MyHomePageState extends State<MyHomePage> {
  Calendar calendarView = Calendar.day;
  int _counter = 0;
  final TextEditingController _controller = TextEditingController();
  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  void _showModalBottomSheet(BuildContext context) {
    showModalBottomSheet(
    context: context,
    builder: (BuildContext context) {
      return SizedBox(
        height: 200,
        child: Center(
          child: Text('这是一个从底部弹出的面板'),
        ),
      );
    },
  );
}

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Container(
        color: Colors.orange,
        child: Column(
          spacing: 10,  
          children: [
            Center(
             child:  Container(
              width: 150,
              height: 150,
              color: Colors.pink,
            )),
            FloatingActionButton( // 按钮
              onPressed:()=>_showModalBottomSheet(context),
              child: Icon(Icons.add),
              ),
              SizedBox(
                width: 220,
                child: TextField( // 编辑框
                controller: _controller,
                decoration: InputDecoration(
                border: OutlineInputBorder(),
                labelText: "输入框"
                ),
              ),
            ),
            SegmentedButton<Calendar>(
              segments: const <ButtonSegment<Calendar>>[
      ButtonSegment<Calendar>(
          value: Calendar.day,
          label: Text('Day'),
          icon: Icon(Icons.calendar_view_day)),
      ButtonSegment<Calendar>(
          value: Calendar.week,
          label: Text('Week'),
          icon: Icon(Icons.calendar_view_week)),
      ButtonSegment<Calendar>(
          value: Calendar.month,
          label: Text('Month'),
          icon: Icon(Icons.calendar_view_month)),
      ButtonSegment<Calendar>(
          value: Calendar.year,
          label: Text('Year'),
          icon: Icon(Icons.calendar_today)),
    ],
    selected: <Calendar>{calendarView},
    onSelectionChanged: (Set<Calendar> newSelection) {
      setState(() {
        calendarView = newSelection.first;
      });
    },
  )
          ]
        )
      )
    );
  
  }
}

// 列表组件
class ListComponent extends StatelessWidget {
  const ListComponent({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView(
        children: [
          Container(
            width: 100,
            height: 100,
            color: Colors.deepPurpleAccent,
          ),
          Container(
            width: 100,
            height: 100,
            color: Colors.deepPurpleAccent,
          )
        ],
      );
  }
}